#Locking down violence 10.18.22
#Replication file 
#Appendix Egypt and Syria Chi square
####################################################################################
#Packages
library(ggplot2)
library(tidyverse)
####################################################################################
rm(list=ls()) #Clearing workspace
####################################################################################
#EGYPT
####################################################################################

#Curfew Chisquare test
load(file= "Egypt.lock.chi.Rdata", verbose = FALSE)
chisq.test(Egypt.lock.chi, simulate.p.value = TRUE)

#Curfew Chisquare plot 
load(file= "E.lock.chi.plot.Rdata", verbose = FALSE)

ggplot(data=E.lock.chi.plot, aes(x=Region, y=Events, fill=time)) +
  geom_bar(stat="identity", position=position_dodge())+
  theme_bw()+
  scale_fill_manual(values=c("gray", "black"))+
  theme(panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        axis.ticks.y=element_blank(),
        axis.ticks.x=element_blank(),
        axis.text.x = element_text(angle = 70,hjust=.9,family="Times New Roman", size = 11),
        axis.text.y = element_text(family="Times New Roman",size = 11),
        axis.title.x = element_text(family="Times New Roman", size = 12),
        axis.title.y = element_text(family="Times New Roman", size = 12))+
  annotate(geom="text", x=.8, y=98, label="Chi-square",
           color="black", angle=0, size=4, fontface="bold",family="Times New Roman")+ #adds text on xy coordinates
  annotate(geom="text", x=.8, y=92, label="p = 0.4743",
           color="black", angle=0, size=4, fontface="bold",family="Times New Roman") #adds text on xy coordinates



####################################################################################
#SYRIA
####################################################################################

#Curfew Chisquare test
load(file= "Syria.lock.chi.Rdata", verbose = FALSE)
chisq.test(Syria.lock.chi, simulate.p.value = TRUE)

#Curfew Chisquare plot 
load(file= "S.lock.chi.plot.Rdata", verbose = FALSE)

ggplot(data=S.lock.chi.plot, aes(x=Region, y=Events, fill=time)) +
  geom_bar(stat="identity", position=position_dodge())+
  theme_bw()+
  scale_fill_manual(values=c("gray", "black"))+
  theme(panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        axis.ticks.y=element_blank(),
        axis.ticks.x=element_blank(),
        axis.text.x = element_text(angle = 70,hjust=.9,family="Times New Roman", size = 11),
        axis.text.y = element_text(family="Times New Roman", size = 11),
        axis.title.x = element_text(family="Times New Roman", size = 12),
        axis.title.y = element_text(family="Times New Roman", size = 12))+
  annotate(geom="text", x=1.5, y=98, label="Chi-square",
           color="black", angle=0, size=4, fontface="bold",family="Times New Roman")+ #adds text on xy coordinates
  annotate(geom="text", x=1.5, y=92, label="p = 0.1409",
           color="black", angle=0, size=4, fontface="bold",family="Times New Roman") #adds text on xy coordinates
